<template>
	<view style="padding: 20upx;">
		<uni-data-checkbox mode="list" icon="right" v-model="value" :localdata="range" @change="change">
		</uni-data-checkbox>
		<view class="" style="margin-top: 40upx;">
			<text>上传视频截图</text>
			<robby-image-upload v-model="imageData" @delete="deleteImage" @add="addImage" :limit="limitNumber"></robby-image-upload>
		</view>
		<view class="" style="margin-top: 10upx;">
			<text>其他</text>
			<textarea name="" id="" cols="30" rows="10"
				style="background-color: #fff;color: #999999;padding: 12upx;margin-top: 20upx;width: 660upx;"
				placeholder="详细举报内容" v-model="tips"></textarea>
		</view>
		<view class="bottom" style="padding: 0;">
			<view class="btn" @click="fabu">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	import {
		pathToBase64,
		base64ToPath
	} from '@/components/mmmm-image-tools/index.js'
	import robbyImageUpload from '@/components/robby-image-upload/robby-image-upload.vue'
	export default {
		data() {
			return {
				enableDel: false,
				enableAdd: false,
				enableDrag: false,
				limitNumber: 1,
				imageData: [],
				formData: {
					userId: 2
				},
				value: [],
				imageValue: [],
				chooseImg: [],
				imageStyles: {
					width: 100,
					height: 100,
					background: '#fff'
				},
				imgurl: '',
				range: [{
					"value": 0,
					"text": "广告、营销"
				}, {
					"value": 1,
					"text": "诈骗、托儿"
				}, {
					"value": 2,
					"text": "色情低俗"
				}, {
					"value": 3,
					"text": "恶意骚扰、不文明行为"
				}, {
					"value": 4,
					"text": "虚假信息"
				}],
				type: '',
				tips: '',
				mid: '',
				br_id: '',
				shipinid: '',
				shopid: ''
			}
		},
		onLoad(option) {
			this.mid = option.userid
			this.br_id = option.br_uid
			this.shipinid = option.shipin_id
			this.shopid = option.shop_id
		},
		components: {
			robbyImageUpload
		},
		methods: {
			deleteImage: function(e) {
				console.log(e)
			},
			addImage: function(e) {
				uni.showToast({
					title: "正常上传",
					icon: 'loading'
				})
				// this.chooseImg = e.files
				// console.log('选择文件：', e.files)
				pathToBase64(e.allImages[0]).then(base64 => {
					// console.log(this.turl,"this.turlthis.turl")
					uni.request({
						url: 'https://dsx.cdzer.com/merchants/Video/uploadImage', //仅为示例，并非真实接口地址。
						data: {
							cover_image: base64
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
						},
						method: 'POST',
						success: (res) => {
							console.log(res, "上传视频封面")
							this.imgurl = res.data.data.image_url
						}
					});
				}).catch(error => {
					console.log(error)
				})
				console.log(e)
			},
			fabu() {
				
				console.log(this.br_id, this.shopid, this.shipinid)
				this.$http.shipinjubao({
					type: this.type,
					tips: this.tips,
					mid: this.br_id,
					pic: this.imgurl,
					shop_id: this.shopid,
					video_id: this.shipinid
				}).then(res => {
					console.log(res, "举报")
					if (res.status == 200) {
						uni.showToast({
							title: res.mess
						})
						this.value = []
						this.tips = '详细举报内容'
						this.imageValue = []
						setTimeout(()=>{
							// uni.reLaunch({
							// 	url:'/pages/index/index'
							// })
							uni.navigateBack({
								delta:1
							})
						},1100)
					} else {
						uni.showToast({
							title: res.mess,
							icon: 'none'
						})
					}
				})
			},
			change(e) {
				console.log('e:', e.detail.data.text);
				this.type = e.detail.data.text
			},
			select(e) {
				
			},
			// 获取上传进度
			progress(e) {
				console.log('上传进度：', e)
			},
			// 上传成功
			success(e) {
				console.log('上传成功')
			},
			// 上传失败
			fail(e) {
				console.log('上传失败：', e)
			},
		}
	}
</script>

<style lang="scss">
	/deep/ .file-picker__box-content {
		background-color: #fff;
	}

	.bottom {
		width: 100%;
		// position: fixed;
		// bottom: 0;
		margin-top: 250upx;
		height: 100upx;
		// background-color: #FFFFFF;
		display: flex;
		justify-content: center;
		z-index: 99;
		left: 0;
		align-items: center;

		.btn {
			width: 690upx;
			height: 80upx;
			background-color: #FA3534;
			text-align: center;
			line-height: 80upx;
			border-radius: 10upx;
			color: #fff;
		}
	}
</style>
